package com.lxl.hadoop.flowsum;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.mapred.JobConf;
import org.apache.hadoop.mapreduce.Partitioner;

/**
 * @Author lixilin
 * @Date 2021/12/30 19:48
 * @Description
 */
public class SelfPartitioner extends Partitioner<LongWritable, FlowBean> {

    @Override
    public int getPartition(LongWritable key, FlowBean value, int numPartitions) {
        String pre = key.toString().substring(0,3);
        if ("136".equals(pre)) {
            return 0;
        }
        if ("137".equals(pre)) {
            return 1;
        }
        if ("138".equals(pre)) {
            return 2;
        }
        if ("139".equals(pre)) {
            return 3;
        }
        return 4;
    }
}
